Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Module: Shodan Ports (InternetDB) #911

Merged
merged 5 commits into from
Jan 3, 2024

Conversation

cnnrshd
Copy link
Contributor

@cnnrshd cnnrshd commented Dec 18, 2023

This module checks Shodan's host endpoint to get and report open TCP ports.. Additional information includes verified vulnerabilities, unverfied vulnerabilities (reported as a FINDING), CPE data, OS data, and DNS information.

@TheTechromancer
Copy link
Collaborator

Thanks for the PR. I'll work on reviewing.

@TheTechromancer TheTechromancer self-assigned this Dec 19, 2023
@cnnrshd
Copy link
Contributor Author

cnnrshd commented Dec 21, 2023

I actually just wrote a much simpler module that uses Shodan's InternetDB API instead of Shodan Proper - no API key required and the only missing data is the "verified" vulnerabilities that you might want to check out - cnnrshd@0d3c828

Haven't written any tests though

@TheTechromancer
Copy link
Collaborator

TIL about internetdb. I like the idea, especially since it's free and has higher rate limits.

I'm about halfway through reviewing this one, so let's leave this PR open, and I'll just modify this one to use internetdb instead. Sound good?

@cnnrshd
Copy link
Contributor Author

cnnrshd commented Dec 21, 2023

That works for me. InternetDB is only updated weekly, but the use case of passive port scanning implies you don't need entirely accurate results anyway imo.

@TheTechromancer TheTechromancer changed the base branch from stable to dev December 22, 2023 00:11
@TheTechromancer
Copy link
Collaborator

TheTechromancer commented Dec 22, 2023

@cnnrshd thanks for you work on this. The internetdb updates have been made and the tests have been written. I made a few other modifications to the module to ensure it works with both IP_ADDRESS and DNS_NAME and that it only accepts in-scope events. (Your solution of changing the scope distance was clever but dangerous since it would have affected other modules).

Please test it out and lmk if you're okay with the changes.

@TheTechromancer TheTechromancer changed the title New Module: Shodan Ports New Module: Shodan Ports (InternetDB) Dec 22, 2023
Copy link

codecov bot commented Dec 22, 2023

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (4c9ecb9) 92% compared to head (ebee44d) 92%.

Files Patch % Lines
bbot/modules/internetdb.py 72% 19 Missing ⚠️
bbot/modules/templates/shodan.py 90% 3 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##             dev    #911    +/-   ##
======================================
- Coverage     92%     92%    -0%     
======================================
  Files        297     300     +3     
  Lines      18498   18604   +106     
======================================
+ Hits       16989   17086    +97     
- Misses      1509    1518     +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheTechromancer TheTechromancer merged commit 75c1919 into blacklanternsecurity:dev Jan 3, 2024
8 checks passed
@joostgrunwald
Copy link

Quick question @cnnrshd when do you consider a vulnerability 'verified', is shodan actually sure about it's presence or it is still purely version based. I was under the impression shodan data was almost fully version based.

@cnnrshd
Copy link
Contributor Author

cnnrshd commented Apr 22, 2024

@joostgrunwald Verified comes from Shodan's definition - if you check the source code (I'd direct reference, but I'm on mobile) for this module, I believe I just pull data from a "vulns" key in the internetdb response. This is probably done with version checking, I don't think they do active verification.

@TheTechromancer
Copy link
Collaborator

Also it's worth noting that the vulns are tracked by IP address, not hostname. So it's possible something in the past shared that IP address, but has since been replaced.

@joostgrunwald
Copy link

joostgrunwald commented Apr 22, 2024

@cnnrshd ah yes I checked the source code but thought I might be missing something. Note that there
are actually a few vulnerabilities that Shodan verifies, they call those verified vulnerabilities and they test them: https://www.shodan.io/search/facet?query=net%3A0%2F0&facet=vuln.verified. Knowing this the usage of 'verified shodan vulns' was a little strange.

@cnnrshd
Copy link
Contributor Author

cnnrshd commented Apr 22, 2024

@joostgrunwald I don't think that the internetdb API differentiates between vulns and verified vulns, but yeah, the wording could be changed.

@joostgrunwald
Copy link

@cnnrshd No you are correct, even though implementation of this would simply be hardcoding the list of verified vulnerabilities and checking against them (the list is that small), I'm not sure how much impact that has based on the small amount of verified vulnerabilities supported.

@TheTechromancer
Copy link
Collaborator

@joostgrunwald I don't think that the internetdb API differentiates between vulns and verified vulns, but yeah, the wording could be changed.

Agreed we should probably change the wording

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants